package com.info.examples.strategy;

import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 满减促销
 */
@Service
public class FullReductionPromoteServiceImpl implements PromoteSalesService {

    // 满 199 减 50
    @Override
    public BigDecimal getPromotionPrice(BigDecimal originalPrice) {
        if (new BigDecimal("199").compareTo(originalPrice) > 0) {
            return originalPrice;
        }
        return originalPrice.subtract(new BigDecimal("50"));
    }

    @Override
    public PromoteTypeEnum getType() {
        return PromoteTypeEnum.FULL_REDUCTION;
    }
}
